/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cadi.games;

import com.cadi.aux.Clickable;
import com.cadi.aux.Window;
import com.cadi.menu.MainMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;

/**
 *
 * @author Luis Eduardo Garay
 */
public class IdentifyBill extends Window  {
    
    private final JLabel goalImage;
    private final JLabel instructions;
    private final Clickable option1, option2, option3;
    private final MouseAdapter toNextLevel;
    private int currentLevel;
    private JLabel background;
    
    public IdentifyBill(boolean faces){
        super();
        if(faces){
            voiceFirst();
        }
        currentLevel = 1;
        toNextLevel = new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent evt){
                switch(currentLevel){
                    case 1:
                        setLevelTwoFace();
                        currentLevel++;
                        break;
                    case 2:
                        setLevelThreeFace();
                        currentLevel++;
                        break;
                    case 3:
                        setLevelFourFace();
                        currentLevel++;
                        break;
                    case 4:
                        setLevelFiveFace();
                        currentLevel++;
                        break;
                    case 5:
                        setLevelSixFace();
                        currentLevel++;
                        break;
                    case 6:
                        MainMenu next = new MainMenu();
                        window.setVisible(false);
                        break;
                        
                    case 11:
                        setLevelTwoNumber();
                        currentLevel++;
                        break;
                    case 12:
                        setLevelThreeNumber();
                        currentLevel++;
                        break;
                    case 13:
                        setLevelFourNumber();
                        currentLevel++;
                        break;
                    case 14:
                        setLevelFiveNumber();
                        currentLevel++;
                        break;
                    case 15:
                        setLevelSixNumber();
                        currentLevel++;
                        break;
                    case 16:
                        MainMenu next1 = new MainMenu();
                        window.setVisible(false);
                        break;
                       
                    case 21:
                        setLevelTwoColor();
                        currentLevel++;
                        break;
                    case 22:
                        setLevelThreeColor();
                        currentLevel++;
                        break;
                    case 23:
                        setLevelFourColor();
                        currentLevel++;
                        break;
                    case 24:
                        setLevelFiveColor();
                        currentLevel++;
                        break;
                    case 25:
                        setLevelSixColor();
                        currentLevel++;
                        break;
                    case 26:
                        MainMenu next2 = new MainMenu();
                        window.setVisible(false);
                        break;
                }
                
            }};
        toMenu.setVisible(true);
        goalImage = new JLabel(new ImageIcon(getClass().getResource("/resources/billete20_noFace.jpg")));
        goalImage.setBounds(100, 100,300 , 170);
        instructions = new JLabel(new ImageIcon(getClass().getResource("/resources/identifyFace_instruction.png")));
        instructions.setBounds(150, 300, 200, 162);
        option1 = new Clickable(new ImageIcon(getClass().getResource("/resources/face50.png")));
        option2 = new Clickable(new ImageIcon(getClass().getResource("/resources/face20.png")));
        option2.setGoal(true);
        option2.setEvent(20);
        option2.addMouseListener(toNextLevel);
        option3 = new Clickable(new ImageIcon(getClass().getResource("/resources/face200.png")));
        option1.setBounds(500, 300, 100, 145);
        option2.setBounds(650, 300, 100, 145);
        option3.setBounds(800, 300, 100, 145);
        container.add(goalImage, JLayeredPane.PALETTE_LAYER);
        container.add(instructions, JLayeredPane.PALETTE_LAYER);
        container.add(option1, JLayeredPane.PALETTE_LAYER);
        container.add(option2, JLayeredPane.PALETTE_LAYER);
        container.add(option3, JLayeredPane.PALETTE_LAYER);
        background = new JLabel(new ImageIcon(getClass().getResource("/resources/fondo6.png")));
        background.setBounds(0, 0, 1280,800);
        container.add(background, JLayeredPane.PALETTE_LAYER);
        window.setVisible(true);
    }
    
    public void setLevelTwoFace(){
        option2.removeMouseListener(toNextLevel);
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_noFace.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/face500.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/face100.png")));
        option2.setEvent(0);
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/face50.png")));
        option3.setGoal(true);
        option3.setEvent(50);
        option3.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    
    public void setLevelThreeFace(){
        option3.removeMouseListener(toNextLevel);
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete100_noFace.jpg")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/face200.png")));
        option3.setEvent(0);
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/face20.png")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/face100.png")));
        option1.setGoal(true);
        option1.setEvent(100);
        option1.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    
    public void setLevelFourFace(){
        option1.removeMouseListener(toNextLevel);
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_noFace.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/face20.png")));
        option1.setEvent(0);
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/face500.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/face200.png")));
        option2.setGoal(true);
        option2.setEvent(200);
        option2.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    
    public void setLevelFiveFace(){
        option2.removeMouseListener(toNextLevel);
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete500_noFace.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/face50.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/face200.png")));
        option2.setEvent(0);
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/face500.png")));
        option3.setGoal(true);
        option3.setEvent(500);
        option3.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    
    public void setLevelSixFace(){
        option3.removeMouseListener(toNextLevel);
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete1000_noFace.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/face1000.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/face200.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/face100.png")));
        option3.setEvent(0);
        option1.setGoal(true);
        option1.setEvent(1000);
        option1.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    
    public void setLevelOneNumber(){
        currentLevel = 11;
        instructions.setIcon(new ImageIcon(getClass().getResource("/resources/identifyNumber_instruction.png")));
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete20_noNumber.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/number100.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/number20.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/number500.png")));
        window.repaint();
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/numeros.wav"));
        voice.play();
    }
    
    public void setLevelTwoNumber(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_noNumber.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/number50.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/number1000.png")));
        option2.setEvent(0);
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/number100.png")));
        option2.removeMouseListener(toNextLevel);
        option1.setGoal(true);
        option1.setEvent(50);
        option1.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelThreeNumber(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete100_noNumber.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/number20.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/number500.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/number100.png")));
        option1.removeMouseListener(toNextLevel);
        option1.setEvent(0);
        option3.setGoal(true);
        option3.setEvent(100);
        option3.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelFourNumber(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_noNumber.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/number200.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/number50.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/number500.png")));
        option3.removeMouseListener(toNextLevel);
        option3.setEvent(0);
        option1.setGoal(true);
        option1.setEvent(200);
        option1.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelFiveNumber(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete500_noNumber.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/number1000.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/number500.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/number100.png")));
        option1.removeMouseListener(toNextLevel);
        option1.setEvent(0);
        option2.setGoal(true);
        option2.setEvent(500);
        option2.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelSixNumber(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete1000_noNumber.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/number200.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/number50.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/number1000.png")));
        option2.removeMouseListener(toNextLevel);
        option2.setEvent(0);
        option3.setGoal(true);
        option3.setEvent(1000);
        option3.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    
    public void setLevelOneColor(){
        currentLevel = 21;
        instructions.setIcon(new ImageIcon(getClass().getResource("/resources/identifyColor_instruction.png")));
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete20_noColor.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/billete20_red.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/billete20.jpeg")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/billete20_green.png")));
        option1.setBounds(500, 200, 300, 200);
        option2.setBounds(675, 400, 300, 200);
        option3.setBounds(850, 200, 300, 200);
        window.repaint();
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/color.wav"));
        voice.play();
    }
    
    public void setLevelTwoColor(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_noColor.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/billete50.jpg")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_blue.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_green.png")));
        option2.removeMouseListener(toNextLevel);
        option2.setEvent(0);
        option1.setGoal(true);
        option1.setEvent(50);
        option1.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelThreeColor(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete100_noColor.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/billete100_pink.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/billete100_blue.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/billete100.jpg")));
        option1.removeMouseListener(toNextLevel);
        option1.setEvent(0);
        option3.setGoal(true);
        option3.setEvent(100);
        option3.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelFourColor(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_noColor.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/billete200.jpg")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_red.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_blue.png")));
        option3.removeMouseListener(toNextLevel);
        option3.setEvent(0);
        option1.setGoal(true);
        option1.setEvent(200);
        option1.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelFiveColor(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete500_noColor.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/billete500_blue.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/billete500.jpeg")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/billete500_pink.png")));
        option1.removeMouseListener(toNextLevel);
        option1.setEvent(0);
        option2.setGoal(true);
        option2.setEvent(500);
        option2.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }
    public void setLevelSixColor(){
        goalImage.setIcon(new ImageIcon(getClass().getResource("/resources/billete1000_noColor.jpg")));
        option1.setIcon(new ImageIcon(getClass().getResource("/resources/billete1000_red.png")));
        option2.setIcon(new ImageIcon(getClass().getResource("/resources/billete1000_green.png")));
        option3.setIcon(new ImageIcon(getClass().getResource("/resources/billete1000.jpg")));
        option2.removeMouseListener(toNextLevel);
        option2.setEvent(0);
        option3.setGoal(true);
        option3.setEvent(1000);
        option3.addMouseListener(toNextLevel);
        window.repaint();
        voice.play();
    }

    private void voiceFirst() {
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/caras.wav"));
        voice.play();
    }
    
    
}
